package org.yf.samples.dao;


import java.util.List;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import org.yf.samples.model.ExamTestType;

@Repository
@Transactional
public class ExamTestTypeDAOImpl extends BaseHibernateDAO<ExamTestType> implements IExamTestTypeDAO {

	@Override
	public List<ExamTestType> FindAllExamTestTypes() {
		return this.find("FROM ExamTestType");
	}

	@Override
	public ExamTestType getExamTestTypeById(Integer id) {
		return this.get(id);
	}

	@Override
	public Integer createExamTestType(ExamTestType examTestType) throws Exception {
		ExamTestType exsitsExamTestType = this.get(examTestType.getId());
		if(exsitsExamTestType != null){
			this.save(examTestType);
		}
		return 1;
	}

	@Override
	public Integer editExamTestType(ExamTestType examTestType) throws Exception {
		this.update(examTestType);
		return 1;
	}

	@Override
	public Integer deleteExamTestType(Integer id) throws Exception {
		ExamTestType exsitsExamTestType = this.get(id);
		if(exsitsExamTestType != null){
			this.delete(exsitsExamTestType);
		}
		return 1;
	}

}
